#include <string>
#include <set>
#include <map>
#include <cstdlib>
#include "AVLTree.hpp"
void test1()
{
  //set的基本使用
  //底层是红黑树
  std::set<int> S;
  S.insert(5);
  S.insert(3);
  S.insert(4);
  S.insert(1);
  S.insert(2);
  S.insert(8);
  S.insert(7);
  S.insert(9);
  std::set<int>::iterator it=S.begin();
  while(it!=S.end())
  {
    std::cout<<*it<<" ";
    ++it;
  }
  std::cout<<std::endl;
  
}

void test2()
{
  //map的基本使用
  //底层是红黑树
  std::map<string,int> M;
  string F[]={"苹果","苹果","苹果","香蕉","香蕉","梨子","梨子","梨子","梨子"};
  for(auto str:F)
  {
   // pair<map<string,int>::iterator,bool> ret=M.insert(make_pair(str,int()));
   // ret.first->second++;
   M[str]++;
  }

  for(auto elem:M)
  {
    cout<<elem.first<<":"<<elem.second<<" ";
  }
  cout<<endl;
}

void test3()
{
  srand(time(NULL));
  int N=1000;
  int tmp;
  AVLTree<int,int> T;
  for(int i=0;i<N;++i)
  {
    tmp=rand()%30000;
    T.insert(make_pair(tmp,tmp));
  }
  T.InOrder();
  cout<<"树的高度为:"<<T.Highet()<<endl;
  cout<<"是否为AVL树:"<<T.IfAVLTree()<<endl;
}

int main()
{
  test3();
  return 0;
}
